Advanced Options#
import panel as pn
import waloviz as wv
wv.extension()
In WaloViz there are a few features which are situational and nuanced, these advanced options make WaloViz more than just simple, but powerful.
The following demonstrations are examples of advanced options and their effects in action, for the full list of options go to the Reference Manual.
Resampling#
To display an audio with a different sample-rate, just set the sr variable in addition to the source:
pn.Row(
wv.Audio("local_data/Yoshi.wav", minimal=True),
wv.Audio("local_data/Yoshi.wav", minimal=True, sr=8000),
)
This has a “crop” like effect in the frequency axis.
Notice how the audio quality has degraded.
Axes Limits#
If you desire a “crop” like effect without any audio degradation, you can use the axes_limits option:
def waveform(wav, sr):
return wav
pn.Row(
wv.Audio(
"local_data/Yoshi.wav",
waveform,
minimal=True,
axes_limits=dict(Hz=(0, 4000), y=(0, 0.5)),
),
wv.Audio(
"local_data/Yoshi.wav",
waveform,
minimal=True,
axes_limits=dict(Hz=(1000, 9000), y=(-0.5, 0)),
),
)
Over Curve Axes#
When you have multiple overlaid curves you can set each of them to a different axis with the over_curve_axes:
import torch
def envelope(wav, sr):
return torch.nn.functional.max_pool1d(wav, kernel_size=101, stride=50, padding=50)
pn.Row(
wv.Audio(
"local_data/Yoshi.wav",
{"wav": waveform, "env": envelope},
over_curve_axes={"wav": "y", "env": "y"},
minimal=True,
),
wv.Audio(
"local_data/Yoshi.wav",
{"wav": waveform, "env": envelope},
over_curve_axes={"wav": "y", "env": "z"},
minimal=True,
),
)
Spectrogram Resolution#
To set the spectrogram to a different resolution in frequency or time, use the frame_ms and hop_ms variables:
pn.Row(
wv.Audio("local_data/Yoshi.wav", minimal=True, frame_ms=50, hop_ms=25),
wv.Audio("local_data/Yoshi.wav", minimal=True, frame_ms=0.5, hop_ms=0.25),
)
Colors#
To set the colormap use cmap, and set colorbar=True for a log scale color bar:
pn.Row(
wv.Audio("local_data/Yoshi.wav", minimal=True, cmap="viridis", colorbar=True),
wv.Audio("local_data/Yoshi.wav", minimal=True, cmap="jet", colorbar=True),
)
Theme#
You can set the bokeh theme with the theme option, a string will load one of the predefined themes of bokeh:
"dark_minimal""light_minimal""caliber""contrast""night_sky"
pn.Row(
wv.Audio("local_data/Yoshi.wav", minimal=True, theme="light_minimal"),
wv.Audio("local_data/Yoshi.wav", minimal=True, theme="night_sky"),
)
Download & Native Player#
You can use the download_button and native_player options to show or hide them:
pn.Row(
wv.Audio("local_data/Yoshi.wav"),
wv.Audio("local_data/Yoshi.wav", download_button=False, native_player=True),
)
Title#
Use the title to set an name for the player, it will be used when saving the plot to an HTML file, also you can embed the title with the player with the embed_title option:
pn.Row(
wv.Audio("local_data/Yoshi.wav"),
wv.Audio("local_data/Yoshi.wav", title="Big Yoshi", embed_title=True),
)